package com.hzc.springchan.service.impl.business;

import com.hzc.springchan.bean.entity.UserEntity;
import com.hzc.springchan.bean.request.Request;
import com.hzc.springchan.bean.response.MapDataResponse;
import com.hzc.springchan.constant.System;
import com.hzc.springchan.mapper.UserMapper;
import com.hzc.springchan.service.IBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 查看用户信息业务处理类
 * @Author: chen990627
 * @Date: 2022/11/07
 * **/
@Service(System.ApiBusinessName.GET_USER_INFO)
public class GetUserInfoBusiness implements IBusinessService<Request, MapDataResponse> {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void doBusiness(Request request, MapDataResponse response) {

        Integer userId = request.getUserId();
        Map<String, Object> userMap = new HashMap<>(8);
        userMap.put("userId", userId);
        List<UserEntity> userEntityList = userMapper.findByOption(userMap);
        UserEntity userEntity = userEntityList.get(0);

        response.getData().put("userName", userEntity.getUserEmail());
        response.getData().put("nickName", userEntity.getNickName());
        response.getData().put("userStatus", userEntity.getUserStatus());
        response.getData().put("createTime", userEntity.getCreateTime());
        response.setSuccess();
    }
}
